package com.boy.tool.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import cn.hutool.core.util.StrUtil;
/**
 * @author whd
 * @date 2024/06/17 11:09:24
 */
/*
*提取出字符串中的数字和汉字
* getFirst  是数字
* getSecond  是汉字
* */
public class StringUtil {
    public static Pair<Integer, String> extractNumbersAndChinese(String inputString) {
        Pattern pattern = Pattern.compile("\\((\\d+)([\\p{Script=Han}]+)\\)");
        Matcher matcher = pattern.matcher(inputString);

        Integer number = null;
        String chinese = null;

        if (matcher.find()) {
            number = Integer.parseInt(matcher.group(1));
            chinese = matcher.group(2);
        }

        return new Pair<>(number, chinese);
    }

}
